#include <unistd.h>
#include "thread_pool.hpp"

void func(int data){
    //sleep(5);
    printf("data is %d\n",data);
}


int main(){
    ThreadPool* tp = new ThreadPool(4);
    if(tp == NULL){
        return 0;
    }

    if(tp->OnInit() <= 0){
        return 0;
    }

    for(int i = 0; i < 100000; i++){
        QueueData qd(i, func);
        tp->Push(qd);
    }

    //一定是将数据处理完了之后才退出的
    tp->ThreadPoolExit();

    sleep(2);
    delete tp;
    return 0;
}
